package com.xmgong.hxdemo.chatmodule.views.face;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.xmgong.hxdemo.chatmodule.R;
import com.xmgong.hxdemo.chatmodule.common.adapter.FragmentsAdapter;
import com.xmgong.hxdemo.hmframe.diyviews.CircleIndicator;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by xmgong on 2017/8/18.
 */

public class Fragment_Faces extends Fragment {

    ViewPager viewpager;
    CircleIndicator circleIndicator;

    List<Fragment> fragments = new ArrayList<>();
    FragmentsAdapter fragmentsAdapter;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_face, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        viewpager = view.findViewById(R.id.vp);
        circleIndicator = view.findViewById(R.id.circle);

        initData();
    }


    private void initData() {
        fragments.clear();

        fragments.add(new Fragment_FaceItem());
        fragments.add(new Fragment_FaceItem());

        fragmentsAdapter = new FragmentsAdapter(getChildFragmentManager(), fragments);
        viewpager.setAdapter(fragmentsAdapter);
        circleIndicator.setViewPager(viewpager);
    }
}
